package g_proxy.a_remote.client;

import g_proxy.a_remote.server.Config;
import g_proxy.a_remote.server.RemoteService;
import g_proxy.a_remote.server.User;

import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

/**
 * Created by wug on 2016/7/4 0004.
 */
public class ProxyService {
    private RemoteService remoteService;

    public ProxyService() {
        try {
            Registry registry = LocateRegistry.getRegistry(0);
            remoteService = (RemoteService) registry.lookup(Config.OBJECT_NAME);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public User login(String name, String pwd) {
        try {
            User user = remoteService.login(name, pwd);
            return user;
        } catch (RemoteException e) {
            e.printStackTrace();
        }
        return null;
    }
}
